/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package openrule;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;

/**
 *
 * @author leadiv
 */
public class VerticalTickBar extends TickBar implements Drawable {
    public VerticalTickBar()
    {
        super();
    }
    
    @Override
    public void draw(Graphics g) 
    {
        Dimension d = new Dimension();
        int i = 0;
        int spacegap = 2;
        int textOffset;
        int fontSize = 9;
        
        this.getSize(d);
        for(;i < d.height; i+=spacegap)
        {
            switch(i % 20)
            {
                case 0:
                    g.drawLine(d.width, i, d.width - this.largeTickHeight, i);
                    g.setFont(new Font("SansSerif", Font.PLAIN, fontSize));
                    textOffset = (((int)Math.log10(i) + 1) * 4) + 1;
                    textOffset = textOffset != 2 ? textOffset : 0;
                    g.drawString(Integer.toString(i), d.width - this.largeTickHeight - textOffset - 2, (i != 0) ? i * (spacegap / 2) + (fontSize / 2) : fontSize - 1);
                break;
                
                case 10:
                    g.drawLine(d.width, i, d.width - this.mediumTickHeight, i);
                break;
                
                default:
                    g.drawLine(d.width, i, d.width - this.smallTickHeight, i);
            }
        }
    }
}
